<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - animation shorthand, two animations with one time
   value each</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#the-animation-shorthand-property-">
   <meta name="flags" content="dom">
   <meta name="assert" content="If the animation shorthand has two
   comma-separated values with one time value each, both time values are
   'animation-duration's">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes move-right {
         from {
            left: 0px;
         }
         to {
            left: 100px;
         }
      }
      @keyframes move-down {
         from {
            top: 0px;
         }
         to {
            top: 200px;
         }
      }
      div {
         width: 100px;
         height: 100px;
         background: blue;
         position: relative;
      }
      .test {
         animation: move-right 0.5s forwards linear, 1s move-down linear;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var div = document.querySelector('div');
         var log = document.querySelectorAll('p')[1].firstChild;
         var style = getComputedStyle(div, null);
         var passed = undefined;
         function aboutEqual(observed, actual) {
            var maxDeviation = 100;
            return (Math.abs(observed - actual) < maxDeviation);
         }
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 2000);
         div.addEventListener('animationstart', function() {
            passed = (passed !== false && aboutEqual(Date.now() - start, 0));
         });
         div.addEventListener('animationend', function(evt) {
            if (evt.animationName == 'move-right') {
               passed = (passed && aboutEqual(Date.now() - start, 500)
                         && style.left == '100px'
                         && parseFloat(style.top) >= 100);
            } else if (evt.animationName == 'move-down') {
               clearTimeout(timeout);
               passed = (passed && aboutEqual(Date.now() - start, 1000)
                         && style.left == '100px' && style.top == 'auto');
               test(function(){assert_true(passed);}, testName); done();
               log.data = (passed ? 'PASS if the animation occurred.' : 'FAIL');
            }
         });
         var start = Date.now();
         div.className = 'test';
      }
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>The blue square below should slide diagonally down+right, then directly
   downwards, then jump upwards.</p>
   <p>Testing...</p>
   <div></div>
</body>
</html>
